package cn.com.guage.dtm.check.datasource.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import cn.com.guage.dtm.check.datasource.aop.DataSourceType.DataBaseType;

@Aspect
@Component
public class DataSourceAspect {
	
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Before("execution(* cn.com.guage.dtm.check.mapper.db1..*.*(..))")
	public void setDataSourceDB01() {
		logger.info("切换数据源为db01业务");
		DataSourceType.setDataBaseType(DataBaseType.DB01);
	}
	
	@Before("execution(* cn.com.guage.dtm.check.mapper.db2..*.*(..))")
	public void setDataSourceDB02() {
		logger.info("切换数据源为db02业务");
		DataSourceType.setDataBaseType(DataBaseType.DB02);
	}
}
